<h1 align="center" style="margin:10px 0 10px 0;">Create Job From Template <?php echo $model->job; ?></h1>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'select-task-grid',
    'dataProvider' => $searchModel->templateSearch($idArr,0),
	'filter' => $searchModel,
    'columns' => array(
        'taskid',
        'tcode',
        'subcode',
        'task',
        'tco',
        array(
            'class' => 'CLinkColumn',
            'header' => '操作', //显示表名称
            'headerHtmlOptions' => array('width'=>'10%'),
            'labelExpression' => '详情', //显示名称
            'urlExpression' => 'Yii::app()->createUrl("task/popView",array("id"=>$data->taskid,"t"=>1))', //显示URL
//            'urlExpression' => 'Yii::app()->createUrl("personTask/view",array("id"=>$data->ptid))', //显示URL
            'linkHtmlOptions' => array('id' => 'taskDetail','class'=>'iframe'),
            'htmlOptions' => array('style'=>'text-align:center;'),            
        ),
		array(
            'class' => 'CCheckBoxColumn',
            'name' => 'taskid',
            'id' => 'taskDelete',
            'selectableRows' => 2,
            'footer' => '<button type="button" onclick="GetCheckboxDel();" >Delete</button>',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
    ),
));
?>

<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'task-grid',
    'dataProvider' => $searchTaskModel->templateSearch($idArr,1),
    'filter' => $searchTaskModel,
    'columns' => array(
        'taskid',
        'tcode',
        'subcode',
        'task',
        'tco',
        /*
          'sco',
          'periodic',
          'urgency',
          'complete',
          'group',
          'estart',
          'rstart',
          'eend',
          'rend',
          'status',
          'follow_up_person',
          'remark',
          'created_by',
          'updated_by',
          'create_time',
          'update_time',
         */
		array(
            'class' => 'CLinkColumn',
            'header' => '操作', //显示表名称
            'headerHtmlOptions' => array('width'=>'10%'),
            'labelExpression' => '详情', //显示名称
            'urlExpression' => 'Yii::app()->createUrl("task/popView",array("id"=>$data->taskid,"t"=>1))', //显示URL
//            'urlExpression' => 'Yii::app()->createUrl("personTask/view",array("id"=>$data->ptid))', //显示URL
            'linkHtmlOptions' => array('id' => 'taskDetail','class'=>'iframe'),
            'htmlOptions' => array('style'=>'text-align:center;'),            
        ),
        array(
            'class' => 'CCheckBoxColumn',
            'name' => 'taskid',
            'id' => 'taskSelect',
            'selectableRows' => 2,
            'footer' => '<button type="button" onclick="GetCheckbox();" >Select</button>',
            'htmlOptions' => array('style'=>'text-align:center;'),
        ),
    ),
));
?>
<form action="<?=Yii::app()->createUrl("personDate/popCreateFromTemplateSave")?>" name="jobForm" id="jobForm" method="post">
<div style="width:100%;" align="center">
Time: <input type="text" name="TaskTime" id="TaskTime" value="<?=date('Ymd')?>" readonly="readonly" style="margin-left:30px;" />
<input type="button" onclick="displayCalendar(document.jobForm.TaskTime,'yyyymmdd',this)" value="Cal">
<input type="submit" name="jobSub" id="jobSub" value="Submit" style="margin-left:100px;" />
</div>
<input type="hidden" id="Task[parent]" name="Task[parent]" value="<?=$model->pdid?>"/>
</form>
<script type="text/javascript">
/*<![CDATA[*/
var GetCheckbox = function (){
	var data=new Array();
    $("input:checkbox[name='taskSelect[]']").each(function (){
    	if($(this).attr("checked")=='checked'){
        	data.push($(this).val());
        }
    });
    if(data.length > 0){
        $.post('<?php echo CHtml::normalizeUrl(array('/personDate/assignTemplate'));?>',{'taskSelect[]':data,'id':<?=$model->pdid?>}, function (data) {
            var ret = $.parseJSON(data);
            if (ret != null && ret.success != null && ret.success) {
				//alert(ret.msg);
				window.location.href = '<?php echo CHtml::normalizeUrl(array('/personDate/popCreateFromTemplate&id='.$model->pdid));?>';
        	}
        });
    }else{
    	alert("请选择要关联的任务!");
    }
}
/*]]>*/
/*<![CDATA[*/
var GetCheckboxDel = function (){
    var data=new Array();
    $("input:checkbox[name='taskDelete[]']").each(function (){
	    if($(this).attr("checked")=='checked'){
            data.push($(this).val());
        }
    });
    if(data.length > 0){
        $.post('<?php echo CHtml::normalizeUrl(array('/personDate/assignTemplate')); ?>',{'taskDelete[]':data,'id':<?= $model->pdid ?>}, function (data) {
            var ret = $.parseJSON(data);
            if (ret != null && ret.success != null && ret.success) {
                //alert(ret.msg);
                window.location.href = '<?php echo CHtml::normalizeUrl(array('/personDate/popCreateFromTemplate&id=' . $model->pdid)); ?>';
            }
        });
    }else{
        alert("请选择要删除的关联任务!");
    }
}
/*]]>*/
</script>